" This wipes all existing custom settings. Useful to avoid conflicts.
sanitize tridactyllocal tridactylsync

"-----------------------------------------------------------------------------
" Misc
"-----------------------------------------------------------------------------

" Removing bindings that cause conflicts
unbind --mode=normal t
unbind --mode=normal B
unbind --mode=normal s

" Use flags with bmarks command
set completions.Bmark.autoselect false

" Use vim as an editor
set editorcmd xterm -e vim

"-----------------------------------------------------------------------------
" Search
"-----------------------------------------------------------------------------

" Use smart case
set findcase smart

" Ctrl-F should use the browser's native 'find' functionality.
unbind <C-f>

" More intuitive search
bind / fillcmdline find
bind ? fillcmdline find -?
bind n findnext 1
bind N findnext -1
bind ,c nohlsearch

"-----------------------------------------------------------------------------
" Tabs and navigation
"-----------------------------------------------------------------------------

" Close all tabs with keyword (not fuzzy matching)
command closebykeyword jsb -p browser.tabs.query({}).then(tabs => tabs.forEach( t => { if(t.url.includes(JS_ARG)) browser.tabs.remove(t.id) }))
bind D fillcmdline closebykeyword

" More bindings
bind O fillcmdline tabopen
bind ' tab #
bind b fillcmdline bmarks
bind B fillcmdline bmarks -t
bind t fillcmdline tab
bind s fillcmdline tgroupswitch

" Search URLs
set searchurls.hn https://hn.algolia.com/?q=%s
set searchurls.mr https://search.marginalia.nu/search?query=%s&js=&adtech=&searchTitle=&profile=&recent= 
set searchurls.wy https://wiby.me/?q=%s
set searchurls.yt https://yewtu.be/search?q=%s

"-----------------------------------------------------------------------------
" Misc that should be at the end
" For some reason, seturl wasnt working properly when put above. So I moved it
" and allowautofocus here
"-----------------------------------------------------------------------------

" Disable autofocus for better experience
set allowautofocus false

" Allow autofocus for some sites
seturl .*leetcode.* allowautofocus true
seturl .*gmail.* allowautofocus true
